//edit页面使用begin ===========================================================
//var params = {};
//var current = {};
//var defaultPageSize = 10;
//var currentPage = 1;
//var pageSize = defaultPageSize;
//var option = {};
// 编辑入口
$(function() {
	var id = localStorage.getItem("rowId");
	localStorage.removeItem("rowId");
	getEntityById(id);
	$('.add').on('click', updateEntity);
	$('.empty').on('click', cancel);
	$('#storageManagerQuery').on('click', employeeQuery);
	$("#storageManagerName").bind('click', function() {
		lovEmployee('storageManager');
	});
	// $('#materielQuery').on('click', queryMatLov);
	// $("#materielName").bind('click', function() {
	// lovMateriel(-1);
	// });
	// $("#segment1").bind('click', function() {
	// lovMateriel(-1);
	// });
	$('#storageQuery').on('click', queryStorageLov);
	$("#storageName").click(lovStorage);
	// 订单
	$('#orderQuery').on('click', queryOrderLov);
	$("#poNum").click(lovOrder);
});

var seq = 1;
function getEntityById(id) {
	$.ajax({
		url : webUrl + 'in/getEntityById.do',
		type : 'post',
		data : {
			id : id
		}
	}).done(
			function(data) {
				var d = data.bo;
				// 初始化
				$("#instorageId").val(d.instorageId);
				if (d.instorageDate != null) {
					$('#instorageDate').datebox('setValue',
							formatDate(new Date(d.instorageDate)));
				}
				if (d.poNum != null) {
					$("#poNum").val(d.poNum);
				}
				if (d.poHeaderId != null) {
					$("#poHeaderId").val(d.poHeaderId);
				}
				if (d.poLineId != null) {
					$("#poLineId").val(d.poLineId);
				}
				if (d.storageId != null) {
					$("#storageId").val(d.storageId);
				}
				if (d.storageName != null) {
					$("#storageName").val(d.storageName);
				}
				if (d.materielId != null) {
					$("#materielId").val(d.materielId);
				}
				if (d.materielName != null) {
					$("#materielName").val(d.materielName);
				}
				// if (d.vendorId != null) {
				// $("#vendorId").val(d.vendorId);
				// }
				// if (d.materielTypeId != null) {
				// $("#materielTypeId").val(d.materielTypeId);
				// }
				if (d.segment1 != null) {
					$("#segment1").val(d.segment1);
				}
				if (d.materielQuantity != null) {
					$("#materielQuantity").val(d.materielQuantity);
				}
				if (d.materielUnit != null) {
					$("#materielUnit").val(d.materielUnit);
				}
				if (d.storageManager != null) {
					$("#storageManager").val(d.storageManager);
				}
				if (d.storageManagerName != null) {
					$("#storageManagerName").val(d.storageManagerName);
				}
				if (d.remark != null) {
					$("#remark").val(d.remark);
				}
			});
}
function cancel() {
	$('.main_panel').load(webUrl + "public/page/storage/in/query.html");
}
// edit页面使用end =============================================================
